package com.oocl.ita.manager.controller.manageShop;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.oocl.ita.service.ManageShopService;
import com.oocl.ita.service.impl.ManageShopServiceImpl;

/**
 * Servlet implementation class ToWhiteShop
 */
public class ToWhiteShop extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ToWhiteShop() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		ManageShopService manageShopService = new ManageShopServiceImpl();
		manageShopService.sendToWhite(Integer.valueOf(request.getParameter("shopId")));	
		int index = Integer.valueOf(request.getParameter("index"));
		int begin = 0;
		int end = 9;
		if(index > 10){
			begin = (index / 10 ) * 10;
			end = (index / 10) * 10 + 9;
		}
		HttpSession httpSession = request.getSession();
		httpSession.setAttribute("begin", begin);
		httpSession.setAttribute("end", end);
		request.getRequestDispatcher("ShowManageShop").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
